"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConnection = exports.PrimaryGeneratedColumn = exports.Column = exports.Entity = void 0;
require("reflect-metadata");
var Typeorm = __importStar(require("typeorm"));
var typeorm_1 = require("typeorm");
var redis_1 = __importStar(require("../redis"));
__exportStar(require("typeorm"), exports);
var Entity = function () {
    var args = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        args[_i] = arguments[_i];
    }
    return function (constructor) {
        typeorm_1.Entity.apply(Typeorm, args)(constructor);
        redis_1.Entity.apply(redis_1.default, args)(constructor);
    };
};
exports.Entity = Entity;
var Column = function () {
    var args = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        args[_i] = arguments[_i];
    }
    return function (target, propertyKey) {
        typeorm_1.Column.apply(Typeorm, args)(target, propertyKey);
        redis_1.Column.apply(redis_1.default, args)(target, propertyKey);
    };
};
exports.Column = Column;
var PrimaryGeneratedColumn = function () {
    var args = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        args[_i] = arguments[_i];
    }
    return function (target, propertyKey) {
        typeorm_1.PrimaryGeneratedColumn.apply(Typeorm, args)(target, propertyKey);
        redis_1.Column.apply(redis_1.default, args)(target, propertyKey);
    };
};
exports.PrimaryGeneratedColumn = PrimaryGeneratedColumn;
var createConnection = function (entities) {
    return Typeorm.createConnection({
        type: 'mysql',
        host: process.env.MYSQL_HOST,
        port: process.env.MYSQL_PORT ? Number(process.env.MYSQL_PORT) : undefined,
        username: process.env.MYSQL_USERNAME,
        password: process.env.MYSQL_PASSWORD,
        database: process.env.MYSQL_DATABASE,
        synchronize: false,
        logging: true,
        charset: 'utf8mb4',
        dateStrings: true,
        timezone: "+08:00",
        entities: entities
    });
};
exports.createConnection = createConnection;
